//
//  UserHeadInfoCell.m
//  ChatForHot
//
//  Created by FLY on 2018/10/13.
//  Copyright © 2018年 FLY. All rights reserved.
//

#import "UserHeadInfoCell.h"

@implementation UserHeadInfoCell

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
    
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    
    if (self) {
        self.backgroundColor = [UIColor clearColor];
        self.clipsToBounds = YES;
        [self layoutViews];
    }
    
    return self;
}

- (void)layoutViews{
    
    [self.contentView addSubview:self.HOTCHATbackView];
    [self.contentView addSubview:self.HOTCHATnameLab];
    [self.contentView addSubview:self.HOTCHATonlineLab];
    [self.contentView addSubview:self.HOTCHATvipImgView];
    [self.contentView addSubview:self.HOTCHATcertifyImgView];
    [self.contentView addSubview:self.HOTCHATinfoLab];
    [self.contentView addSubview:self.HOTCHATdistanceLab];
    [self.contentView addSubview:self.HOTCHATjobLab];
    [self.contentView addSubview:self.HOTCHATlineView];
    
    [self.HOTCHATbackView mas_updateConstraints:^(MASConstraintMaker *make) {
       
        make.left.top.right.equalTo(self.contentView);
        make.height.mas_equalTo(150);
    }];
    [self.HOTCHATnameLab mas_updateConstraints:^(MASConstraintMaker *make) {
        
        make.left.equalTo(self.contentView.mas_left).mas_offset(8);
        make.top.equalTo(self.contentView.mas_top).mas_offset(15);
        make.right.lessThanOrEqualTo(self.contentView).offset(-106);
    }];
    [self.HOTCHATcertifyImgView mas_updateConstraints:^(MASConstraintMaker *make) {
        
        make.left.equalTo(self.HOTCHATnameLab.mas_right).mas_offset(5);
        make.centerY.equalTo(self.HOTCHATnameLab.mas_centerY);
        make.height.width.mas_equalTo(17);
    }];
    [self.HOTCHATvipImgView mas_updateConstraints:^(MASConstraintMaker *make) {
       
        make.left.equalTo(self.HOTCHATcertifyImgView.mas_right).mas_offset(5);
        make.centerY.equalTo(self.HOTCHATnameLab.mas_centerY);
        make.height.width.mas_equalTo(17);
    }];
    
    [self.HOTCHATonlineLab mas_updateConstraints:^(MASConstraintMaker *make) {
        
        make.right.equalTo(self.contentView.mas_right).mas_offset(-15);
        make.centerY.equalTo(self.HOTCHATvipImgView.mas_centerY);
        
    }];
    [self.HOTCHATinfoLab mas_updateConstraints:^(MASConstraintMaker *make) {
        
        make.left.equalTo(self.HOTCHATnameLab.mas_left);
        make.top.equalTo(self.HOTCHATnameLab.mas_bottom).mas_offset(8);
        make.right.lessThanOrEqualTo(self.HOTCHATdistanceLab).offset(20);
    }];
    [self.HOTCHATdistanceLab mas_updateConstraints:^(MASConstraintMaker *make) {
        
        make.right.equalTo(self.contentView.mas_right).mas_offset(-15);
        make.centerY.equalTo(self.HOTCHATinfoLab.mas_centerY);
        
    }];
    [self.HOTCHATjobLab mas_updateConstraints:^(MASConstraintMaker *make) {
        
        make.left.equalTo(self.HOTCHATnameLab.mas_left);
        make.top.equalTo(self.HOTCHATinfoLab.mas_bottom).mas_offset(8);
        
    }];
    [self.HOTCHATlineView mas_updateConstraints:^(MASConstraintMaker *make) {
        make.bottom.equalTo(self.contentView);
        make.left.right.equalTo(self.contentView);
        make.height.mas_equalTo(0.5);
        
    }];
}
- (void)setModel:(UserInfoModel *)model{
    
    _model = model;
    if (model) {
        
        NSString *imgStr = @"";
        if (model.isWrite.integerValue == 1) {
            
            imgStr = @"all_ic_writevip";
        }else if (model.isDiamonds.integerValue == 1) {
            
            imgStr = @"all_ic_diamondsvip";
        }else if (model.isExtreme.integerValue == 1) {
            
            imgStr = @"all_ic_vip";
        }else{
            
            self.HOTCHATvipImgView.hidden = YES;
            
        }
        
        self.HOTCHATvipImgView.image = [UIImage imageNamed:imgStr];
        
        if (model.isApprove.integerValue != 1) {
            
            [self.HOTCHATvipImgView mas_updateConstraints:^(MASConstraintMaker *make) {
                
                make.left.equalTo(self.HOTCHATnameLab.mas_right).mas_offset(5);
                make.centerY.equalTo(self.HOTCHATnameLab.mas_centerY);
                make.height.width.mas_equalTo(17);
            }];
        }
        
        if (model.isApprove.integerValue != 1) {
            //renzheng
            self.HOTCHATcertifyImgView.hidden = YES;
            
        }else{
            self.HOTCHATcertifyImgView.hidden = NO;
            if ([[NSString stringWithFormat:@"%@",model.sex] integerValue] == 0) {
                //women
                self.HOTCHATcertifyImgView.image = [UIImage imageNamed:@"certify_women"];
            }else{
                
                self.HOTCHATcertifyImgView.image = [UIImage imageNamed:@"certify_man"];
            }
        }
        if (HOTCHATAPPINFO.isVIP.integerValue == 1) {
            
            self.HOTCHATonlineLab.text = HOTCHATAPPINFO.onlineStatus.integerValue == 1 ? @"ONLINE" : model.lastLogin;
            self.HOTCHATonlineLab.textColor = HOTCHATHexColor(0x1E1E1E);
        }else{
            self.HOTCHATonlineLab.textColor = HOTCHATMainColor;
            self.HOTCHATonlineLab.text = NSLocalizedString(@"StrN038", nil);
        }
        self.HOTCHATnameLab.text = model.nickName;
        
        self.HOTCHATinfoLab.text = [NSString stringWithFormat:@"%@yr / %@’%@” / %@",model.age,model.minFeet,model.maxFeet,[UserInfoModel HOTCHATgetTypeNameWith:[NSString stringWithFormat:@"%@",model.weight]]];
        
        self.HOTCHATdistanceLab.text = [NSString stringWithFormat:@"%@",model.distance];
        
        self.HOTCHATjobLab.text = [NSString stringWithFormat:@"%@",[UserInfoModel HOTCHATgetJobNameWithID:[NSString stringWithFormat:@"%@",model.occupation]]];
    }
    
}
//lzzy

- (UIView *)HOTCHATbackView{
    
    if (_HOTCHATbackView == nil) {
        
        _HOTCHATbackView = [[UIView alloc]init];
        _HOTCHATbackView.backgroundColor = [UIColor whiteColor];
        _HOTCHATbackView.layer.masksToBounds = YES;
        _HOTCHATbackView.layer.cornerRadius = 8;
        
    }
    return _HOTCHATbackView;
}
- (UIImageView *)HOTCHATcertifyImgView{
    
    if (_HOTCHATcertifyImgView == nil) {
        
        _HOTCHATcertifyImgView = [[UIImageView alloc]init];
        
        
        _HOTCHATcertifyImgView.contentMode = UIViewContentModeScaleAspectFill;
    }
    return _HOTCHATcertifyImgView;
}
- (UIImageView *)HOTCHATvipImgView{
    
    if (_HOTCHATvipImgView == nil) {
        
        _HOTCHATvipImgView = [[UIImageView alloc]init];
        
    }
    return _HOTCHATvipImgView;
}
- (UILabel *)HOTCHATnameLab{
    
    if (_HOTCHATnameLab == nil) {
        
        _HOTCHATnameLab = [[UILabel alloc]init];
        _HOTCHATnameLab.textColor =HOTCHATHexColor(0x1E1E1E);
        _HOTCHATnameLab.font = [UIFont boldSystemFontOfSize:20];
        
    }
    return _HOTCHATnameLab;
}
- (UILabel *)HOTCHATonlineLab{
    
    if (_HOTCHATonlineLab == nil) {
        
        _HOTCHATonlineLab = [[UILabel alloc]init];
       
        _HOTCHATonlineLab.font = [UIFont systemFontOfSize:12];
        
    }
    return _HOTCHATonlineLab;
}

- (UILabel *)HOTCHATinfoLab{
    
    if (_HOTCHATinfoLab == nil) {
        
        _HOTCHATinfoLab = [[UILabel alloc]init];
        _HOTCHATinfoLab.textColor =HOTCHATHexColor(0x444444);
        _HOTCHATinfoLab.font = [UIFont boldSystemFontOfSize:14];
        
    }
    return _HOTCHATinfoLab;
}
- (UILabel *)HOTCHATdistanceLab{
    
    if (_HOTCHATdistanceLab == nil) {
        
        _HOTCHATdistanceLab = [[UILabel alloc]init];
        _HOTCHATdistanceLab.textColor =HOTCHATHexColor(0x979797);
        _HOTCHATdistanceLab.font = [UIFont boldSystemFontOfSize:14];
        
    }
    return _HOTCHATdistanceLab;
}
- (UILabel *)HOTCHATjobLab{
    
    if (_HOTCHATjobLab == nil) {
        
        _HOTCHATjobLab = [[UILabel alloc]init];
        _HOTCHATjobLab.textColor =HOTCHATHexColor(0x444444);
        _HOTCHATjobLab.font = [UIFont boldSystemFontOfSize:14];
        
    }
    return _HOTCHATjobLab;
}
- (UIView *)HOTCHATlineView{
    
    if (_HOTCHATlineView == nil) {
        
        _HOTCHATlineView = [[UIView alloc]init];
        _HOTCHATlineView.backgroundColor = HOTCHATHexColor(0xF0F0F0);
    }
    return _HOTCHATlineView;
}
@end
